package array.nowcoder.easy;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * @author bruin_du
 * @description 求和
 * @date 2022/7/4 18:44
 **/
public class Sum {
    static List<List<Integer>> lists = new ArrayList<>();
    static List<Integer> list = new ArrayList<>();
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        sum(n,m,0);
        for (List<Integer> i : lists) {
            for (Integer j : i) {
                System.out.print(j + " ");
            }
            System.out.println();
        }
    }

    private static boolean sum(int n, int m,int count) {
        if(count > m) {
            return false;
        }else if(count == m) {
            List<Integer> newList = new ArrayList<>(list);
            lists.add(newList);
            return true;
        }
        for (int i = n; i > 0; i--) {
            list.add(n);
            if(!sum(i - 1, m, count + i)) {
                list.remove(list.size() - 1);
            }
        }
        return false;
    }
}
